// 如何给root添加app

//VMDOM
export function createElement(type, props, ...children) {
  return {
    type,
    props: {
      ...props,
      children
    }
  }
}


export function createTextNode(text) {
  return {
    type: "TEXTELEMENT",
    props: {
      nodeValue: text,
      children: []
    }
  }
}

export function render(vmdom, container) {
  const { type, props, props: { children } } = vmdom
  const dom = type === 'TEXTELEMENT' ? document.createTextNode("") : document.createElement(vmdom.type)
  Object.keys(props).forEach(key => {
    if (key !== 'children') {
      dom[key] = props[key]
    }
  })
  console.log(children)
  children.forEach(child => render(child, dom))
  container.append(dom)
  console.log(dom)

}

// render(App, container)
// const el = document.createElement("div")
// el.textContent = "app"
// container.append(el)
// render()
